<template>
  <div class="hd Confirm">
    <div class="hd mt10">
      <img src="../../assets/banner03.png">
    </div>

    <div class="hd mt10">
      <sider-menu :activeNumber="3"></sider-menu>
      <div class="right-content">
        <position style="padding:12px;width:auto;">
          <router-link to="/personal">个人中心</router-link>
          &gt;
          <span class="last">我的快递</span>
        </position>

        <div class="clearfix main">
          
         <iframe 
          :src="wechatSrc" 
          width="100%" 
          height="500" 
          frameborder="no" 
          border="0" 
          scrolling="no" 
          allowtransparency="yes"
        ></iframe>

        </div>
      </div>
    </div>


  </div>
</template>

<script>
import Position from '../../components/Position'
import SiderMenu from '../../components/SiderMenu'
import {requestModifyPassword, PLATFORM_PREFIX, ORG_ID} from  '../../api/api'
import md5 from 'md5'

export default {
  data () {
    return {
      dialogShow: false,
      wechatSrc: '',
      person: JSON.parse(localStorage.person || '{}')
    }
  },
  mounted () {
    if (!localStorage.accessToken) {
			this.$message({message: '请先登录', type: 'error'})
      return
    }
    const accessToken = localStorage.accessToken
    const orgId = ORG_ID
    const mpiId = this.person.mpiId
    this.wechatSrc = `http://wechat.jshtcm.com/cas-wechat/#/setting/myexpress?accessToken=${accessToken}&orgId=${orgId}&mpiId=${mpiId}`
  },
  methods: {
    confirmSubmit (form) {
      this.$refs[form].validate(valid => {
        if (!valid) {
          return false
        }
        if (this.ruleForm.confirmNewPassword !== this.ruleForm.newPassword) {
          this.$message({message: '两次输入的密码不一致', type: 'error'})
          return false
        }
        // 只验证身份证格式
        this.$store.commit('UPDATE_LOADING')
        requestModifyPassword({
          originalPwd: md5(this.ruleForm.oldPassword),
          newPwd: md5(this.ruleForm.newPassword)
        }).then(res => {
          this.$store.commit('UPDATE_LOADING')
          if (res.data.code === 200) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            this.$router.replace('/personal')
            setTimeout(() => location.reload(), 1500)
          } else {
            this.$message({
              message: res.data.msg,
              type: 'error'
            })
          }
        }).catch(res => {
          this.$store.commit('UPDATE_LOADING')
          this.$message({
            message: '请求服务器失败',
            type: 'error'
          })
        })
      })
    }
  },
  components: {Position, SiderMenu}
};
</script>


